|
|
|
|
|
|
|
vbDirectory returns only the subdirectories (or folders) in the specified path. The constant vbVolume causes Dir$ to return the specified drive's volume label. The available constants are summarized in Table 21.1. (You also can display a list of folders with a directory list box.) |
|
|
|
|
| Table 21.1 Constants Control the Behavior of the Dir$ Function | | Constant | Value | Purpose | | vbNormal | 0 | (Default value) | | vbHidden | 2 | Include hidden files | | vbSystem | 4 | Include system files | | vbVolume | 8 | Return drive volume label | | vbDirectory | 16 | Display subdirectories | | vbReadOnly | 1 | Include read-only files |
|
|
|
|
|
|
|
Constants can be added together if you want to use more than one. For example, the following code finds the system, hidden, and read-only file IO.SYS on a Windows 95 machine: |
|
|
|
|
|
|
|
|
Debug.Print Dir$("C:\IO.SYS",vbHidden+vbSystem+vbReadOnly)  |
|
|
|
|
|
|
|
|
|
|
Note that the vbHidden constant refers to a file's attributes and not the Windows Explorer option that hides certain file types. You can view the attributes of a file by right-clicking the file's name and choosing Properties, as depicted in Figure 21.1, or by using the MS-DOS ATTRIB command. |
|
|
|
|
|
|
|
|
Figure 21.1
File attributes, shown in the Windows
Explorer, can determine whether the Dir$ function returns a specific filename. |
|
|
|
|
|